﻿Public Class Gebruikers
    Dim users As New Users

    Private Sub Leerlingen_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Adminmenu.Show()
    End Sub
    Private Sub Leerlingen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If users.LoadAllFromDB() = "True" Then
            For Each row As DataRow In users.UsersDataSet.Tables("Table").Rows()
                ListView1.Items.Add(row.Item("uid")).ToString()
                ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(row.Item("name")).ToString()
                ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(row.Item("ovnummer")).ToString()
                ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(row.Item("level")).ToString()
                If row.Item("disabled").ToString() = "True" Then
                    ListView1.Items(ListView1.Items.Count - 1).SubItems.Add("Ja")
                Else
                    ListView1.Items(ListView1.Items.Count - 1).SubItems.Add("Nee")
                End If

            Next
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Bewerkgebruiker.weergeefGebruiker(ListView1.SelectedItems.Item(0).SubItems.Item(2).Text.ToString) 'Het OVnummer wordt doorgegeven naar Bewerkgebruiker
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Bewerkgebruiker.weergeefGebruiker("", True)
    End Sub

    Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
        If ListView1.SelectedItems.Count.ToString >= 1 Then
            Bewerkgebruiker.weergeefGebruiker(ListView1.SelectedItems.Item(0).SubItems.Item(2).Text.ToString) 'Het OVnummer wordt doorgegeven naar Bewerkgebruiker
        End If
    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        If ListView1.SelectedItems.Count.ToString >= 1 Then
            Button2.Enabled = True
        Else
            Button2.Enabled = False
        End If
    End Sub
End Class